<template>
  <button class="my-button" :class="[`my-button-${type}`, {
 
    'is-circle': circle,
  }]"
 >
  
    <!-- 通过$slots获取插槽数据 -->
    <span><slot></slot></span>


      <!-- i和span元素都必须判断是否有内容，没有内容则不要存在该元素，否则有空白留下 -->
    <i v-if="icon" :class="`iconfont ${icon}`"></i>
  </button>
</template>
<script>
export default {
  name: 'commybutton1',
  props: {
    type: {
      type: String,
      default: 'default'
    },
    plain: {
      type: Boolean,
      default: false
    },
    round: {
      type: Boolean,
      default: false
    },
    circle: {
      type: Boolean,
      default: false
    },
    icon: {
      type: String
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    // 点击事件处理，得传上事件对象e
    handleClick (e) {
      this.$emit('click', e)
    }
  }
}
</script>
<style scoped lang="scss">
.my-button{
  display: inline-block;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  background: #ffffff;
  border: 1px solid #dcdfe6;
  color: #606266;
  -webkit-appearance: nmy;
  text-align: center;
  box-sizing: border-box;
  outline: nmy;
  margin: 0;
  transition: 0.1s;
  font-weight: 500;
  //禁止元素的文字被选中
  padding: 12px 20px;
  font-size: 14px;
  border-radius: 4px;
  &:hover,
  &:focus{
    color: #409eff;
    border-color: #c6e2ff;
    background-color: #ecf5ff;
  }
}
.my-button-primary{
color:#fff;
background-color: #409eff;
border-color: #409eff;
&:hover,
&:focus{
  background: #66b1ff;
  background-color: #66b1ff;
  color: #fff;
  }
}
.my-button-success{
color:#fff;
background-color: #67c23a;
border-color: #67c23a;
&:hover,
&:focus{
  background: #85ce61;
  background-color: #85ce61;
  color: #fff;
  }
}
.my-button-info{
color:#fff;
background-color: #909399;
border-color: #909399;
&:hover,
&:focus{
  background: #a6a9ad;
  background-color: #a6a9ad;
  color: #fff;
  }
}
.my-button-warning{
color:#fff;
background-color: #e6a23c;
border-color: #e6a23c;
&:hover,
&:focus{
  background: #ebb563;
  background-color: #ebb563;
  color: #fff;
  }
}
.my-button-danger{
color:#fff;
background-color: #f56c6c;
border-color: #f56c6c;
&:hover,
&:focus{
  background: #f78989;
  background-color: #f78989;
  color: #fff;
  }
}
// 朴素按钮样式
.my-button.is-plain{
  &:hover,
  &:focus{
    background:rgb(167, 235, 135);
    border-color: red;
    color: red;
  }
}
.my-button-primary.is-plain{
  color: #409eff;
  background: #ecf5ff;
  &:hover,
  &:focus{
    background: #409eff;
    border-color: #409eff;
    color: #fff;
  }
}
.my-button-success.is-plain{
  color: #67c23a;
  background: #c2e7b0;
  &:hover,
  &:focus{
    background: #67c23a;
    border-color: #67c23a;
    color: #fff;
  }
}
.my-button-info.is-plain{
  color: #909399;
  background: #d3d4d6;
  &:hover,
  &:focus{
    background: #909399;
    border-color: #909399;
    color: #fff;
  }
}
.my-button-warning.is-plain{
  color: #e6a23c;
  background: #f5dab1;
  &:hover,
  &:focus{
    background: #e6a23c;
    border-color: #e6a23c;
    color: #fff;
  }
}
.my-button-danger.is-plain{
  color: #f56c6c;
  background: #fbc4c4;
  &:hover,
  &:focus{
    background: #f56c6c;
    border-color: #f56c6c;
    color: #fff;
  }
}
// round属性
.my-button.is-round{
  border-radius: 20px;
  padding: 12px 23px;
}
// circle属性
.my-button.is-circle{
  border-radius: 50%;
  padding: 12px;
}
// icon配套样式
.my-button [class*=my-icon-]+span{
  margin-left: 5px;
}
// disabled属性
.my-button.is-disabled{
   cursor: no-drop;
}
</style>